Flexible bypass Permissions and Controlled Access to Maintenance Mode Nav item#2
Conversation
…nfig/maintenance-mode
…missions will bypass maintenance mode
Greptile SummaryThis PR adds two config-driven features: a configurable list of permissions that allow bypassing maintenance mode (
Confidence Score: 4/5Safe to merge only after the boot-time user-check bug in ServiceProvider is fixed; the bypass-permission changes are correct. One P1 defect: the src/ServiceProvider.php — the boot-time user check must be moved inside the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming Request] --> B{App in maintenance?}
B -- No --> C[Pass through]
B -- Yes --> D{CP route?}
D -- Yes --> C
D -- No --> E{Maintenance status route?}
E -- Yes --> C
E -- No --> F{Authenticated CP user?}
F -- Yes --> G{isSuper?}
G -- Yes --> C
G -- No --> H{has any perm in allow_bypass_for_perms?}
H -- Yes --> C
H -- No --> I{Whitelisted page?}
F -- No --> I
I -- Yes --> C
I -- No --> J[Laravel maintenance handler]
J -- 503 --> K[Custom maintenance response]
subgraph CP_Nav [CP Nav Registration - ServiceProvider boot]
L{show_menu_for_supers_only?}
L -- false --> M[Register utility for all]
L -- true --> N[User::current check - always null at boot]
N --> O[Utility never registered]
end
Reviews (1): Last reviewed commit: "update readme to show that users with at..." | Re-trigger Greptile |
Hi, I came across your package while browsing the statamic addons and it would be perfect for a project I am working on with a few modifications.
I am building an app where thousands of users will have the "access cp" permissions but just a few super users. By changing the maintenance mode bypass from hardcoded "access cp" to a defined array of permissions in config/maintenance-mode we are able to fine-tune the bypass.
The same applies to the maintenance mode control panel view as well. we would obviously not want ALL users with "access cp" to be able to take the website down. Depending on the scenario, we are able to open it up to supers only or all users with "access cp".
PS: array_filter is used instead of array_any for backward compatibility with Statamic 5.